import { Logger } from '../../engine/Logger';
import  ViewBase  from '../../engine/ViewBase';
const { ccclass, property } = cc._decorator;
@ccclass
export class ViewTip extends ViewBase {

    private static tipCount: number = 0;
    private lbTip: cc.Label;
    private bg: cc.Node
    private tipMsg: string = "";

    private pos: cc.Vec3 = cc.v3(0, 200, 0);
    private pianYiY: number = 200;

    onInitChild(tipMsg: string) {
        this.tipMsg = tipMsg;
        ViewTip.tipCount++;
        this.node.setPosition(0, this.pianYiY)
    }

    onEnable() {
        super.onEnable();
        this.setTopUI()
        this.bg = this.getChild(this.node, "bg")
        this.lbTip = this.getChild(this.node, "lbTip", cc.Label);
        this.lbTip.string = this.tipMsg;
        this.scheduleOnce(()=>{
            this.bg.width = this.lbTip.node.width + 30
            this.bg.height = this.lbTip.node.height + 30
        })
        cc.tween(this.node).delay(1).by(1, { position: this.pos }).call(() => {
            this.closeView();
        }).start()
    }

    onDisable() {
        ViewTip.tipCount--;
    }
}

